const {fork} = require('child_process')


// fork以流的形式实现进程之间的通信
var childProcess=fork('fork-child.js');

var index=0;
var intervaId=setInterval(()=>{
    index++;
    childProcess.send('this is message from your parent process')
    if(index==10){
        clearInterval(intervaId)
    }
},1000)



childProcess.on('message',(chunk)=>{
    console.log(chunk)
})